package com.hcl.orm.sample;

import com.hcl.orm.core.annotation.DBType;
import com.hcl.orm.core.annotation.DataAccessScan;
import com.hcl.orm.core.executor.DataSourceTypeLookup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.io.IOException;

/**
 * @author hucl
 * @date
 */
@SpringBootApplication(scanBasePackages = {"com.hcl.orm"})
@DataAccessScan(basePackages = {"com.hcl.orm.sample"})
    public class Application {
        public static final Logger logger = LoggerFactory.getLogger(Application.class);

        public static void main(String[] args) throws IOException {
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
        DBType dbType = context.getBean(DataSourceTypeLookup.class).getDataSourceType("");
        logger.info("当前数据库类型为：" + dbType.toString());
        logger.info("----------------------开始执行自定义示例-------------------------");
        CustomerDaoSample customerDaoSample = new CustomerDaoSample(context);
        customerDaoSample.getFundAccountList();
        customerDaoSample.getBusinessEntrust();
        customerDaoSample.getBusinessEntrustByInitDate();
        customerDaoSample.getBusinentrustQueryPage();
        logger.info("----------------------结束执行自定义示例-------------------------");
        logger.info("----------------------开始执行单表示例-------------------------");
        SimpleDaoSample simpleDaoSample = new SimpleDaoSample(context);
        simpleDaoSample.test();
        logger.info("----------------------结束执行单表示例-------------------------");
        logger.info("----------------------开始执行原生SQL示例-------------------------");
        //原生SQL使用示例
        NativeSqlSample nativeSqlSample = new NativeSqlSample(context);
        nativeSqlSample.test();
        logger.info("----------------------结束执行原生SQL示例-------------------------");
        logger.info("----------------------开始执行性能测试SQL示例-------------------------");
        // 性能测试
        PerformanceSample performanceSample = new PerformanceSample(context);
        performanceSample.test();
        logger.info("----------------------结束执行性能测试SQL示例-------------------------");
    }
}
